﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Caching;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;

namespace Web.frontStage
{
    public partial class thirdGenerationNewsDetail : System.Web.UI.Page
    {
           protected System.Data.DataSet dataSetNews = new DataSet();
           protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["ID"] != null)
            {
                ShowNews(Server.MapPath("/xml/thirdGenerationNews.xml"));
            }
        }
    
        
        private void ShowNews(string path)
        {
            //得到新闻内容并保存在Cache里
            if (Cache["thirdGenerationDataSet"] == null)
            {
                dataSetNews.ReadXml(path);
                Cache.Add(
                    "thirdGenerationDataSet",
                    dataSetNews,
                    null,
                    DateTime.Now.AddSeconds(3600),
                    TimeSpan.Zero,

                    CacheItemPriority.High,
                    null
                    );
            }
            //显示新闻详细信息
            DataRow[] DataRowNews = ((DataSet)Cache["thirdGenerationDataSet"]).Tables[0].Select(String.Format("id='{0}'", Request.QueryString["ID"].ToString()));
            this.TitleLabel.Text = DataRowNews[0]["title"].ToString();
            this.DateLabel.Text = DataRowNews[0]["date"].ToString();
            this.ContentLabel.Text = DataRowNews[0]["content"].ToString().Replace("\n", "<BR>").Replace(" ", "&nbsp;");
            DataBind();

        }
        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);
        }
        #endregion
    }
        }
    